package csse3004.GD.PM;

import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.util.Map;
import java.util.HashMap;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class PollController implements Controller {

    protected final Log logger = LogFactory.getLog(getClass());
    private PollManager pollManager;

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response){

        Map<String, Object> myModel = new HashMap<String, Object>();

        myModel.put("products", this.pollManager.getPolls());

        return new ModelAndView("viewpoll", "model", myModel);
    }

    public void setPollManager(PollManager pollManager) {
        this.pollManager = pollManager;
    }
}